package com.ssy.lingxi.product.entity.commodity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 商品对应的商城中间表
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/13
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_commodity_shop", indexes = {@Index(name = "product_commodity_shop_shop_id_idx", columnList = "shopId"),
        @Index(name = "product_commodity_shop_type_idx", columnList = "type"),
        @Index(name = "product_commodity_shop_environment_idx", columnList = "environment")})
public class CommodityShop implements Serializable {
    private static final long serialVersionUID = 8554102155938786322L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="commodity_shop_seq")
    @SequenceGenerator(sequenceName="product_commodity_shop_seq", name="commodity_shop_seq",allocationSize = 1)
    private Long id;

    /**
     * 商品id
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="commodityId",referencedColumnName = "id")
    private Commodity commodity;

    /**
     * 商城id
     */
    @Column(columnDefinition = "int8")
    private Long shopId;

    /**
     * 商城类型：1.企业商城 2.积分商城 3.渠道商城 4.渠道自有商城 5.渠道积分商城
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer type;

    /**
     * 商城环境:1.web 2.H5 3.小程序 4.APP
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer environment;

}
